#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int n, k;
	cin >> n >> k;
	int ans = n;
	while (n >= k) {
		ans += n / k;
		n = n / k + n % k;
	}
	cout << ans;
	return 0;
}
